<template>
  <div class="card-box" style="min-height: 334px;">
    <div class="card-tit">
      <img src="@/assets/img/home-quick.png" alt="" class="mr6">
      快捷功能
    </div>
    <Row class="mb20">
      <Col :span="6" v-for="item in quickFunctionList" :key="item.id" class="mt40">
        <a @click="goQuickRouter(item)">
          <img :src="getImgUrl(item.name)" alt="" class="disblock mauto">
          <div class="font12 color333 line17 mt10 tc">{{ item.meta.title }}</div>
        </a>
      </Col>
    </Row>
  </div>
</template>

<script>

export default {
  name: "quickFunction",
  props: {},
  data() {
    return {
      quickFunctionList: [],  // 快捷功能
    }
  },
  created() {
    // 快捷功能
    this.quickFunction();
  },
  methods: {
    // 快捷功能
    quickFunction() {
      this.APIS.quickMenu().then((res) => {
        if (res.code == 20000) {
          if (res.data) {
            res.data.map(item => {
              if (item.name === "zhengce" || item.name === "bangzhu") {
                item.parentName = "zhengceguanli";
              } else if (item.name === "juMinLieBiao" || item.name === "zengYuanLieBiao" || item.name === "jianYuanLieBiao") {
                item.parentName = "authorityManagement";
                if (item.name === "zengYuanLieBiao" || item.name === "jianYuanLieBiao") {
                  // 增员、减员跳转 打开新增弹窗
                  item.add = true;
                }
              } else if (item.name === "tongxunlu") {
                item.parentName = "xitongshezhi";
              } else {
                item.parentName = item.name;
              }
              return item;
            })
          }
          this.quickFunctionList = res.data;
        } else {
          this.$Message.error(res.message)
        }
      })
    },
    //  快捷功能跳转
    goQuickRouter(item) {
      localStorage.setItem("menus", item.parentName);
      this.$router.push({
        name: item.name,
        query: {
          tabsName: item.parentId ? item.name : "",
        },
        params: {
          add: item.add ? item.add : false
        }
      })
    },
    //获取图片地址
    getImgUrl(img) {
      return require("@/assets/img/home-" + img + ".png");
    },
  }
}
</script>

<style scoped lang="less">
@import "../style.less";
</style>
